package aop.jboss;

import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;

public class TraceInterceptor implements Interceptor {
	public String getName() {
		return "TraceInterceptor";
	}

	public Object invoke(Invocation invocation) throws Throwable {

		MethodInvocation mi = (MethodInvocation) invocation;
		String methodName = mi.getMethod().getName();

		System.out.println("-> Before " + methodName);
		Object rsp = invocation.invokeNext();
		System.out.println("-> After " + methodName);
		return rsp;
	}
}